/**
  ******************************************************************************
  * @文件     bsp.h
  * @作者     hero_cao
  * @版本     V1.0.0
  * @日期     2018/07/17
  * @概要     BSP硬件初始化库
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BSP_H_
#define __BSP_H_

/* Includes ------------------------------------------------------------------*/
#include "at32f403a_407_gpio.h"

/* Exported types ------------------------------------------------------------*/
typedef enum {
    eLED_1,
    eLED_2,
	eBEEP,
	eLCD_BK,
	eKEY_A,
	eKEY_B,
	eKEY_K,
    eKEY_S,
	eKEY_U,
	eKEY_D,
	eKEY_L,
	eKEY_R,
	eKEY_AA,
	eKEY_BB,
    eGPIO_MAX_COUNT,
}GPIO_ENUM_t;

/* Exported constants --------------------------------------------------------*/
#define DWT_CR				*(uint32_t*)0xE0001000
#define DWT_CYCCNT			*(uint32_t*)0xE0001004
#define DEM_CR				*(uint32_t*)0xE000EDFC
#define DEM_CR_TRCENA		(1<<24)
#define DWT_CR_CYCCNTENA	(1<<0)

/* Exported macro ------------------------------------------------------------*/
#define LED_OFF(a)			BSP_GpioSet(a)          //LED关
#define LED_ON(a)			BSP_GpioReset(a)        //LED开
#define BSP_CONEOF(a)		((sizeof(a)) / (sizeof(*a)))

/* Exported functions ------------------------------------------------------- */
void BSP_Init(void);
void BSP_GpioSet(int n);
void BSP_GpioReset(int n);
int BSP_GpioRead(int n);
void BSP_GpioToggle(int n);
void Delay_us(uint32_t nus);
void Delay_ms(uint16_t nms);


#endif /* __BSP_H_ */
